package com.xcesys.extras.remoting.system.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xcesys.extras.core.service.ITreeCrudService;
import com.xcesys.extras.dataobject.system.Resource;
import com.xcesys.extras.model.TsResource;
import com.xcesys.extras.remoting.BaseRemotingTreeCrudServiceImpl;
import com.xcesys.extras.remoting.system.RResourceService;
import com.xcesys.extras.system.service.TsResourceService;

@Service("RResourceService")
public class RResourceServiceImpl extends
		BaseRemotingTreeCrudServiceImpl<Resource, TsResource> implements
		RResourceService {
	@Autowired
	private TsResourceService service;

	@Override
	public List<Resource> findByType(String type) {
		return (List<Resource>) fromModel(service.findByType(type));
	}

	@Override
	public List<Resource> findByParentIdAndTypes(Long parentId, String[] types) {
		List<TsResource> tmResources = service.findByParentIdAndTypes(parentId,
				types);
		return (List<Resource>) fromModel(tmResources);
	}

	@Override
	protected ITreeCrudService<TsResource> getTreeCrudService() {
		return service;
	}

	@Override
	public List<Resource> findByParentPathInRoles(String parentPath,
			String type, String[] roles) {
		return (List<Resource>) fromModel(service.findByParentPathInRoles(
				parentPath, type, roles));
	}

}
